package com.blockmeta.bbs.businesslibrary.util;

import android.graphics.Color;
import android.text.TextUtils;

import com.blockmeta.bbs.baselibrary.R;
import com.blockmeta.bbs.baselibrary.base.app.BaseApp;
import com.blockmeta.bbs.baselibrary.utils.SharedPreferenceUtil;
import com.blockmeta.bbs.businesslibrary.constant.Constant;
import com.blockmeta.bbs.businesslibrary.provider.InitSdkProvider;

import java.util.ArrayList;
import java.util.List;

/**
 * @author AirThor
 * @date 2019/6/18.
 */
public class ColorUtil {
    /**
     * 根据配置的涨跌颜色返回跌的背景 默认是红色
     *
     * @return 涨跌颜色
     */
    public static int getDownsBg() {
        boolean isUpsGreen = SharedPreferenceUtil.getBoolean(BaseApp.getApp(), Constant.IS_UPS_GREEN, true);
        if (isUpsGreen) {
            return R.drawable.shape_main_bg_red;
        } else {
            return R.drawable.shape_main_bg_green;
        }
    }
    /**
     * 根据配置的涨跌颜色返回涨的背景 默认是绿色
     *
     * @return 涨跌颜色
     */
    public static int getUpsBg() {
        boolean isUpsGreen = SharedPreferenceUtil.getBoolean(BaseApp.getApp(), Constant.IS_UPS_GREEN, true);
        if (isUpsGreen) {
            return R.drawable.shape_main_bg_green;
        } else {
            return R.drawable.shape_main_bg_red;
        }
    }
    /**
     * 根据配置的涨跌颜色返回涨的颜色 默认是绿色
     *
     * @return 涨跌颜色
     */
    public static int getUpsColor() {
        boolean isUpsGreen = SharedPreferenceUtil.getBoolean(BaseApp.getApp(), Constant.IS_UPS_GREEN, true);
        if (isUpsGreen) {
            return Color.parseColor("#29B32A");
        } else {
            return Color.parseColor("#ef4a45");
        }
    }

    /**
     * 根据配置的涨跌颜色返回跌的颜色 默认是红色
     *
     * @return 涨跌颜色
     */
    public static int getDownsColor() {
        boolean isUpsGreen = SharedPreferenceUtil.getBoolean(BaseApp.getApp(), Constant.IS_UPS_GREEN, true);
        if (isUpsGreen) {
            return Color.parseColor("#ef4a45");
        } else {
            return Color.parseColor("#29B32A");
        }
    }

    public static List<String> getColorList() {
        List<String> colorList = new ArrayList<>();
        colorList.add("#1890FF");
        colorList.add("#13C2C2");
        colorList.add("#2FC25B");
        colorList.add("#FACC14");
        colorList.add("#F04856");
        colorList.add("#8543E0");
        colorList.add("#3436C7");
        colorList.add("#223273");
        return colorList;
    }

    public static int getColor(String color) {
        if (TextUtils.isEmpty(color)) return Color.BLACK;
        if (!color.startsWith("#")) color = "#" + color;
        return Color.parseColor(color);
    }
}
